#ifndef IDC_UBUS_ENTRY_H
#define IDC_UBUS_ENTRY_H
#include "idc_ubus_common.h"

/**
 * num表示通道号为0，表示控制所有通道，大于0表示控制指定通道
 * val值为0表示关闭，1表示打开；如果
*/
enum {
        SLEEP_TIME,
        WORK_TIME,
        __SLEEP_WAKE_MAX,
} ;
static const struct blobmsg_policy entry_set_addr_policy[] = {
    [0] = { .name = "addr", .type = BLOBMSG_TYPE_STRING },
    [1] = { .name = "group_addr", .type = BLOBMSG_TYPE_STRING },
}; 
static const struct blobmsg_policy set_sleep_wake_policy[] = {
        [0] = { .name = "hours", .type = BLOBMSG_TYPE_INT32 },
        [1] = { .name = "minutes", .type = BLOBMSG_TYPE_INT32 },
        [2] = { .name = "seconds", .type = BLOBMSG_TYPE_INT32 },
}; 

static const struct blobmsg_policy set_energy_id_policy[] = {
        [0] = { .name = "id", .type = BLOBMSG_TYPE_INT32 },
}; 

static const struct blobmsg_policy set_mt7621_run_mode_policy[] = {
        [0] = { .name = "mode", .type = BLOBMSG_TYPE_INT32 },
}; 
static const struct blobmsg_policy init_lora_nconfig_policy[] = {
        [0] = { .name = "freq", .type = BLOBMSG_TYPE_INT32 },
        [1] = { .name = "lemode", .type = BLOBMSG_TYPE_INT32 },
        [2] = { .name = "txpwr", .type = BLOBMSG_TYPE_INT32 },
        [3] = { .name = "rate", .type = BLOBMSG_TYPE_INT32 },
}; 
/**
 * 设置休眠时间
 */
int set_sleep(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg);
/**
 * 设置工作时间
 */
int set_work(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg);
/**
 * 所哟电源模块，定时器同步
 */
int sync_timer(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg);

/**
 * 控制电源模块休眠
 */
int control_sleep(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg);
/**
 * 控制电源模块唤醒
 */
int control_work(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg);
/**
 * 设置电源模块编号
 */
int set_energy_id(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg);
/**
 * 读取在线设备
 */
int read_devs(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg);
/**
 * 重启MT7621模块
 * 
 */
int reset_mt7621(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg);
/**
 * 设置7621运行模式；mode为0表示运行模式，mode为1表示升级模式（电源模块不检测心跳）
 * 
 */
int set_mt7621_run_mode(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg);
/**
 * 查询电源模块时间信息
 * 
 */
int query_timeinfo(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg);
/**
 * LoRa模块网络初始化
 * 
 */
int test_lora(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg);

#endif